package search.impl;

import search.FileHandler;
import vo.Program;

import java.io.*;
import java.util.List;

public class Handler implements FileHandler
{
	String fileName = "University of Liverpool.txt";
	public int program2File(List<Program> programList)
	{
		System.err.println(programList.size());

		int i = 0;

		StringBuilder builder = new StringBuilder();
		for (Program program : programList)
		{
			if (program != null)
			{
				builder.append(program.toString());
				i++;
			}
		}

		try
		{
			FileOutputStream stream = new FileOutputStream(fileName);

			for (int j = 0; j < builder.toString().length(); j++)
			{
				stream.write(builder.toString().charAt(j));
			}
		}
		catch (FileNotFoundException e)
		{

		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		return i;
	}
}